/**
 * @author LKQ
 * @date 2022/1/30 20:37
 * @description
 */
public class FormalSolution2 {
    public static void main(String[] args) {
        FormalSolution2 solution2 = new FormalSolution2();
        System.out.println(solution2.findComplement(5));
    }
    public int findComplement(int num) {
        int t = num;
        t |= t >> 1;
        t |= t >> 2;
        t |= t >> 4;
        t |= t >> 8;
        t |= t >> 16;
        return ~num & t;
    }
}
